package com.enjoyor.soa.traffic.api.dto.gps;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

import com.enjoyor.soa.traffic.api.dto.gps.TransboundaryTypeEnum;
import oracle.spatial.geometry.JGeometry;

/**
 * 边界信息
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class TransboundaryDto implements Serializable  {
	private static final long serialVersionUID = 1L;

	private int id;
	private String name;
	private String description;
	private DeviceTypeEnum devtype;	//对特定定位设备类型的设备报警
	private String locids;			//对特定定位设备报警（以";"分隔，为空表示全部）
	private JGeometry geom;			//空间数据
	private Integer status;				//启用状态(0:启用，1:未启用)
	private TransboundaryTypeEnum tranType;//围栏类型
	private Date startTime;			//围栏生效起始时间,不为空
	private Date endTime;			//围栏生效截止时间,可为空,表示永久有效
	
	private String departmentname;			//部门名称
	private String departmentid;			//部门id
	
	
	
	
	public String getDepartmentname() {
		return departmentname;
	}
	public void setDepartmentname(String departmentname) {
		this.departmentname = departmentname;
	}
	public String getDepartmentid() {
		return departmentid;
	}
	public void setDepartmentid(String departmentid) {
		this.departmentid = departmentid;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public DeviceTypeEnum getDevtype() {
		return devtype;
	}
	public void setDevtype(DeviceTypeEnum devtype) {
		this.devtype = devtype;
	}
	public String getLocids() {
		return locids;
	}
	/**
	 * @param locids 对特定定位设备报警（以";"分隔，为空表示全部）
	 */
	public void setLocids(String locids) {
		this.locids = locids;
	}
	public JGeometry getGeom() {
		return geom;
	}
	/**
	 * 空间数据
	 */
	public void setGeom(JGeometry geom) {
		this.geom = geom;
	}
	public Integer getStatus() {
		return status;
	}
	/**
	 * 启用状态
	 * @param status 0:启用，1:未启用
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}
	public TransboundaryTypeEnum getTranType() {
		return tranType;
	}
	/**
	 * 围栏类型
	 */
	public void setTranType(TransboundaryTypeEnum tranType) {
		this.tranType = tranType;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}


	//////////////////////
	private List<DatetimeRule> rules;

	public List<DatetimeRule> getRules() {
		return rules;
	}
	public void setRules(List<DatetimeRule> rules) {
		this.rules = rules;
	}

	/**
	 * 规则
	 */
	public static class Rule implements Serializable{
		private static final long serialVersionUID = 1L;

		public Rule(){}
	}
	/**
	 * 速度规则。小于等于maxSpeed未规则范围内，否则为规则外
	 */
	public static class SpeedRule extends Rule{
		public double minSpeed;
		public double maxSpeed;
		public SpeedRule(double maxSpeed){this.maxSpeed = maxSpeed; }
		public SpeedRule(double minSpeed,double maxSpeed){this.minSpeed = minSpeed; this.maxSpeed = maxSpeed; }
	}
	/**
	 * 时间规则
	 */
	public static class DatetimeRule extends Rule{
		public Date minTime;
		public Date maxTime;
		public List<TimeIntervalRule> intervals = new ArrayList<TimeIntervalRule>();
		public SpeedRule speed;
		public DatetimeRule(Date minTime,Date maxTime){this.minTime=minTime;this.maxTime=maxTime;}
		public void addTimeIntervalRule(TimeIntervalRule intervalRule){this.intervals.add(intervalRule);}
	}
	/**
	 * 时段规则。日期格式 HH:mm
	 */
	public static class TimeIntervalRule extends Rule{
		public String start;
		public String end;
		public TimeIntervalRule(String start,String end){this.start=start;this.end=end;}
	}
}
